package org.example.struct.array;

import org.example.node.ListNode;

/**
 * @author liyishan
 * @date 2024/9/5 10:06
 * @apiNote
 */

public class Test01290GetDecimalValue {
    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        head.next = new ListNode(0);
        head.next.next = new ListNode(1);
        System.out.println(getDecimalValue(head));
    }
    public static int getDecimalValue(ListNode head) {
        ListNode curNode = head;
        int ans = 0;
        while(curNode != null){
            ans = ans * 2 + curNode.val;
            curNode = curNode.next;
        }
        return ans;
    }
}
